package 迭代器模式与组合模式;

/**
 * @author zzs
 * @ClassName ApplesIterator.java
 * @Description
 * @createTime 2022年05月18日 18:48:00
 */
public class ApplesIterator implements Iterator {
    private final Integer[] count;
    private int index = 0;

    public ApplesIterator(Integer[] count) {
        this.count = count;
    }

    @Override
    public Object next() {
        Integer i = count[index];
        index++;
        return i;
    }

    @Override
    public boolean hashNext() {
        return index != count.length;
    }
}
